package com.woniuxy.patrol.controller;

import com.woniuxy.patrol.pojo.PatrolCategory;
import com.woniuxy.patrol.service.PatrolCategoryService;
import com.woniuxy.common.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 巡更分类控制器（对应《巡更demo.docx》3.2节巡更分类管理功能）
 */
@RestController
@RequestMapping("/patrol/category")
public class PatrolCategoryController {

    @Resource
    private PatrolCategoryService categoryService;

    @GetMapping("/list")
    public ResponseUtil getByCommunity(@RequestParam Long communityId) {
        return categoryService.getByCommunityId(communityId);
    }

    @PostMapping("/add")
    public ResponseUtil addCategory(@RequestBody PatrolCategory category) {
        return categoryService.addCategory(category);
    }

    @PostMapping("/update")
    public ResponseUtil updateCategory(@RequestBody PatrolCategory category) {
        return categoryService.updateCategory(category);
    }

    @GetMapping("/delete")
    public ResponseUtil deleteCategory(@RequestParam Long categoryId) {
        return categoryService.deleteCategory(categoryId);
    }
}